package com.zenithmind.user.pojo.domain;

import com.baomidou.mybatisplus.annotation.TableName;
import com.zenithmind.common.base.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;

/**
 * 租户配置实体类
 * 
 * @author ZenithMind
 * @since 2024-06-30
 */
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
@Schema(name = "租户配置实体", description = "租户配置信息实体")
@TableName("tenant_config")
public class TenantConfig extends BaseEntity {

    @NotBlank(message = "租户ID不能为空")
    @Schema(description = "租户ID")
    private String tenantId;

    @NotBlank(message = "配置键不能为空")
    @Size(max = 100, message = "配置键长度不能超过100个字符")
    @Schema(description = "配置键")
    private String configKey;

    @Schema(description = "配置值")
    private String configValue;

    @Size(max = 20, message = "配置类型长度不能超过20个字符")
    @Schema(description = "配置类型（STRING,NUMBER,BOOLEAN,JSON）")
    private String configType;

    @Size(max = 500, message = "配置描述长度不能超过500个字符")
    @Schema(description = "配置描述")
    private String description;

    @Schema(description = "是否系统配置（0-否，1-是）")
    private Integer isSystem;

    /**
     * 配置类型枚举
     */
    public enum ConfigType {
        STRING("STRING", "字符串"),
        NUMBER("NUMBER", "数字"),
        BOOLEAN("BOOLEAN", "布尔值"),
        JSON("JSON", "JSON对象");

        private final String code;
        private final String name;

        ConfigType(String code, String name) {
            this.code = code;
            this.name = name;
        }

        public String getCode() {
            return code;
        }

        public String getName() {
            return name;
        }
    }
}
